from core.support import set_cutscene
from core.item import Item
from core.action import Action

class InvisibilityCloak(Item):
    def __init__(self):
        Item.__init__(self, "invisibilitycloak")    # do basic initialization for every item
        self.is_worn = False
        
        # build list of actions
        self.add_action(PutOnCloak)
    
    def get_description(self):
        return "Invisibility Cloak"
    
    def get_image(self):
        return "Cloak.jpg"

# define actions for this item

class PutOnCloak(Action):
    def __init__(self):
        Action.__init__(self, "put_on_cloak")    # do basic initialization for every action
        self.isItemAction=True
    
    # return description of action (used in label on webpage)
    def get_description(self):
        if self.item.is_worn:
            return "Take Off Cloak"
        else:
            return "Put On Cloak"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        #if room.get_id() == 'fifthFloor':
        if self.item.is_worn:
            self.item.is_worn = False
        else:
            set_cutscene("You are now invisible and safe from being cold called upon.")
            self.item.is_worn = True        
        return
    
    def is_enabled(self):
        return True